[C#] Array as DataSource of a DataGrid: how to customize columns?

Posted by pbean on Stack Overflow See other posts from Stack Overflow or by pbean
Published on 2010-06-12T12:13:47Z Indexed on 2010/06/12 12:22 UTC
Read the original article Hit count: 287

In my Windows Mobile .NET application I have a simple array of object with the data I want to display in my DataGrid. To do this, I simply call:

myDataGrid.DataSource = myArray;

This works, but I have a problem with it: it uses all properties as columns and uses the names of the properties as the column headers. I can't figure out how to customize two things:

  • Select which subset of properties should be displayed as columns (say I have an ID, Name and Value property, I'd only want to show Name and Value);

  • Rename the column headers to make more sense (for example if the property is called ID display a column header saying "Number").

Is this possible at all?

As mentioned this is in a Windows Mobile .NET (version 2) application.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET